<!DOCTYPE html>
<html lang="zh-CN">
    <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
      <%= stylesheet_link_tag    'application', media: 'all' %>
      <%= javascript_include_tag 'application' %>
      <%= csrf_meta_tags %>

      <!--标题-->
      <%- if @title==nil %>
          <title>每日知 - 在线学习平台</title>
      <%- else %>
          <title><%= @title %> - 每日知</title>
      <% end %>

      <%- if Rails.env == 'production' %>
        <!--统计代码-->
        <%= render partial: 'common/baidu_tongji' %>
      <% end %>

    </head>

    <body>
        <!--导航条-->
        <nav class="navbar navbar-default">
          <div class="container-fluid">
            <!-- Brand and toggle get grouped for better mobile display -->
            <div class="navbar-header">
              <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
              </button>
              <%= link_to "每日知", root_path, class: "navbar-brand" %>
            </div>

            <!-- Collect the nav links, forms, and other content for toggling -->
            <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
              <ul class="nav navbar-nav">
                <%- if current_user %>
                <li><%= link_to "发布主题", new_topic_path, 'data-no-turbolink' => true  %></li>
                <li class="dropdown">
                  <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">
                    <%= current_user.name %>
                    <span class="caret"></span>
                  </a>
                  <ul class="dropdown-menu" role="menu">
                    <li><%=	 link_to "我的主页", user_topics_path(current_user) %></li>
                    <!--<li><%=	 link_to "我的关注", user_follows_path(current_user) %></li>-->
                    <li class="divider"></li>
                    <li><%=	 link_to "退出", destroy_user_session_path, method: :delete %></li>
                  </ul>
                </li>
                <%- else %>
                <li><%= link_to "注册", new_user_registration_path %></li>
                <li><%= link_to "登陆", new_user_session_path %></li>
                <%- end %>
              </ul>
              <%= form_tag search_path, class: 'navbar-form navbar-right', role: 'search' do %>
                  <div class="form-group">
                    <%= text_field_tag :keywords, nil, class: 'form-control', placeholder: 'Search' %>
                  </div>
                    <%= submit_tag '搜 索', class: 'btn btn-default' %>
              <% end %>

            </div><!-- /.navbar-collapse -->
          </div><!-- /.container-fluid -->
        </nav>

        <div class="container">
            <!--主体导航条-->
            <div class="row">

            </div>
            <!--主体-->
            <div class="row">
              <!--主体左-->
              <div class="col-xs-12 col-sm-8 col-md-8">
                <%= yield %>
              </div>
              <!--主体右边栏-->
              <div class="pdl15 col-xs-12 col-sm-3 col-md-3  col-sm-offset-1 col-md-offset-1">
                <%= render partial: 'common/sidebar' %>
              </div>
            </div>

            <!--页脚-->
            <div class="row mgt30 pdt20 mgb20 border-top color666">
              <%= render partial: 'common/footer' %>
            </div>
        </div>



    </body>
</html>
